using Hospital.API.Dto;
using Hospital.API.HospitalServices.IServices;
using Hospital.Domain;
using Hospital.ErrorCode;
using Hospital.Infrastructrue;
using Microsoft.AspNetCore.Mvc;

namespace Hospital.API.Controllers
{
    /// <summary>
    /// 医生管理控制器
    /// </summary>
    [ApiController]
    [Route("api/[controller][action]")]
    public class DoctorController : ControllerBase
    {
        private readonly IDoctorServices _doctorServices;
        private readonly ILogger<DoctorController> _logger;
        private readonly IBaseRepository<Doctor> _doctorRepository;
        private readonly IBaseRepository<Fan> _fanRepository;

        public DoctorController(
            IDoctorServices doctorServices, 
            ILogger<DoctorController> logger,
            IBaseRepository<Doctor> doctorRepository,
            IBaseRepository<Fan> fanRepository)
        {
            _doctorServices = doctorServices;
            _logger = logger;
            _doctorRepository = doctorRepository;
            _fanRepository = fanRepository;
        }

        /// <summary>
        /// 获取医生列表
        /// </summary>
        /// <param name="queryDto">查询条件</param>
        /// <returns>医生列表</returns>
        [HttpGet]
        public async Task<APIResult<APIPaging<List<DoctorDto>>>> GetDoctorList([FromQuery] DoctorQueryDto queryDto)
        {
            return await _doctorServices.GetList(queryDto);
        }

        /// <summary>
        /// 根据ID获取医生信息
        /// </summary>
        /// <param name="id">医生ID</param>
        /// <returns>医生详细信息</returns>
        [HttpGet]
        public async Task<APIResult<DoctorDto>> GetDoctorById(int id)
        {
            return await _doctorServices.GetById(id);
        }

        /// <summary>
        /// 获取粉丝列表
        /// </summary>
        /// <param name="queryDto">查询条件</param>
        /// <returns>粉丝列表</returns>
        [HttpGet]
        public async Task<APIResult<APIPaging<List<Fan>>>> GetFanList([FromQuery] FanQueryDto queryDto)
        {
            return await _doctorServices.GetFan(queryDto);
        }

        /// <summary>
        /// 更新医生审核状态
        /// </summary>
        /// <param name="updateDto">更新审核状态DTO</param>
        /// <returns>更新结果</returns>
        [HttpPut]
        public async Task<APIResult<bool>> UpdateDoctorAuditStatus([FromBody] UpdateDoctorAuditStatusDto updateDto)
        {
            return await _doctorServices.UpdateAuditStatus(updateDto);
        }
    }
} 